package com.songshuai.sales.tool.controller;


import com.songshuai.sales.tool.service.SopImgService;
import com.songshuai.webapi.baseapi.enumerations.ResultStatus;
import com.songshuai.webapi.baseapi.exception.BusinessException;
import com.songshuai.webapi.baseapi.pojo.QueryRes;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

@Slf4j
@Api("SopImg")
@RestController
@RequestMapping("/api/sopImg/")
public class SopImgController {

    @Autowired
    private SopImgService sopImgService;

    @ApiOperation(value = "图片上传")
    @PostMapping("uploadPicture")
    public QueryRes uploadPicture(@RequestParam(name = "file", required = false) MultipartFile file) {
        try {
            return sopImgService.uploadPicture(file);
        } catch (Exception ex) {
            log.error("api/sopImg/uploadPicture", ex);
            throw new BusinessException(ex.getMessage(), ResultStatus.FAILOfficial);
        }
    }


}
